Skip to main content

Quickstart Flutter

This guide will help you to implement the Group Link SDK on your application written for the Flutter framework.

Requirements

  • Required software:
    • IDE (VSCode or Android Studio)
    • Flutter environment

Step 1 - Getting the SDK

To get our Flutter plugin, run the following command in your project's root directory from your terminal at the root of your Flutter project.

flutter pub add flutter_grouplink_sdk

(Optional) Solving missing files for builds.

Add the JitPack repository to your build file. Add it in your root build.gradle at the end of repositories:

repositories {
google()
mavenCentral()
...
...
//ADD Jitpack repository
maven { url "https://jitpack.io" }
}

Step 2 - Importing the SDK

Next, import our SDK into the main.dart file to access all the SDK functions. Below is an example for reference.

import 'package:flutter_grouplink_sdk/flutter_grouplink_sdk.dart';

Step 3 - Setting up the platform specifics

iOS Specifics

To ensure proper functionality of the plugin on iOS devices, you need to insert specific strings into your application's info.plist file. These strings relate to permissions and app capabilities. You can find detailed instructions on how to insert them by referring to the iOS Required Permissions documentation.

Step 4 - Calling the SDK functions

Now that you have properly installed and imported the SDK plugin, simply call the Flutter functions in your main.dart file. We recommend initializing the Group Link SDK at the beginning of your application on your application void main() function, below is another example of how to start the Group Link SDK. For iOS, you will need to instantiate the GroupLinkSDKPlugin:

final Grouplink = GroupLinkSDKPlugin();

And after, call the StartSDK:

void main() {
Grouplink.startSDK("GROUP_LINK_TOKEN");
// ...
runApp(const MyApp());
}

Asking for Bluetooth and Location permissions

If your app does not request Bluetooth or Location permissions, the Group Link SDK can handle this process for you. However, it is still necessary to ask the user for these permissions for the SDK to function correctly. You can initiate this process by calling the startBluetooth(), startLocation() functions.

void main() {
WidgetsFlutterBinding.ensureInitialized();
// Asking for the Bluetooth and location permission of the user;
GroupLinkSDKPlugin().startBluetooth();
GroupLinkSDKPlugin().startLocation();
// ...
runApp(const MyApp());
}

Getting the user given userID

The userID is an optional String identifier that is unique to each user within the Group Link network. By utilizing this ID, you can identify when a particular user approaches one of our devices.

void main() async {
// Getting the Group Link given userID;
String? userID = await GroupLinkSDKPlugin().getUserId();
runApp(const MyApp());
}

Step 5 - Setting up the Push Notification capability

To utilize our custom notifications in the dashboard, you need to call the GroupLinkSDKPlugin().setNotificationToken function. This function expects a String parameter, which represents the user's notification token. On iOS, this token is provided by APNS (Apple Push Notification Service), while on Android, it is obtained through Firebase Cloud Messaging.

To retrieve this token, you can use the Firebase Messaging plugin for Flutter and invoke the getToken method. Here's an example to guide you:

Android

void main() async {
FirebaseMessaging.instance.getToken().then((value) {
if (value != null) {
GroupLinkSDKPlugin().setNotificationToken(value);
}
});
runApp(const MyApp());
}

iOS

void main() async {
FirebaseMessaging.instance.getAPNSToken().then((value) => {
if (value != null) {
GroupLinkSDKPlugin().setNotificationToken(value);
}
});
runApp(const MyApp());
}

In addition to that, you can also configure our notifications KPIs. However, please note that this functionality is currently only available for native implementation. For iOS, you can refer to the iOS Push Notifications tutorial to learn how to set up the Notification Service Extension, which will enable you to integrate and configure the notifications KPIs.

Now with Group Link SDK into your application and utilize its features seamlessly.